﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _4_5
{
    public partial class Form1 : Form
    {
        private int i = 0;
        public Form1()
        {
            InitializeComponent();
        }

        private void btnStartStop_Click(object sender, EventArgs e)
        {
            if (!timer1.Enabled)
            {
                timer1.Enabled = true;
                btnStartStop.Text = "停止";
            }
            else
            {
                timer1.Enabled = false;
                btnStartStop.Text = "开始";
                pictureBox1.Image = Image.FromFile("bfly2.png"); // 恢复初始图
                i = 0;
            }

        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (i % 2 == 0)
                pictureBox1.Image = Image.FromFile("bfly1.png");
            else
                pictureBox1.Image = Image.FromFile("bfly2.png");
            i++;
        }
    }
}
